package com.example.onlinemarket.model;

import java.util.ArrayList;
import java.util.List;

public class MobileOrderItemInfo {
    private int goodId;
    private int goodNum;
    private boolean del;

    public MobileOrderItemInfo(){
    }

    public MobileOrderItemInfo(int goodId, int goodNum){
        this.goodId = goodId;
        this.goodNum = goodNum;
        this.del = goodNum<=0;
    }

    public static List<MobileOrderItemInfo> getMobileOrderItemInfoList(List<OrderInfo> orderInfoList){
        List<MobileOrderItemInfo> mobileOrderItemInfoList = new ArrayList<>();
        for(OrderInfo orderInfo : orderInfoList){
            for(MobileOrderItem orderItem:orderInfo.orderItemList)
                mobileOrderItemInfoList.add(new MobileOrderItemInfo(orderItem.goodId, orderItem.goodNum));
        }
        return mobileOrderItemInfoList;
    }

    public boolean isDel() {
        return del;
    }

    public void setDel(boolean del) {
        this.del = del;
    }

    @Override
    public String toString() {
        return "MobileOrderItemInfo{" +
                "goodId='" + goodId + '\'' +
                ", goodNum=" + goodNum +
                '}';
    }

    public Integer getGoodId() {
        return goodId;
    }

    public void setGoodId(Integer goodId) {
        this.goodId = goodId;
    }

    public Integer getGoodNum() {
        return goodNum;
    }

    public void setGoodNum(Integer goodNum) {
        this.goodNum = goodNum;
    }
}
